<?php
  function website_form_validation($form) {

    $stat = new set_static_variable();

//Concerned dept validation
	     //chk_concerned_dept($form['field_web_dept']); 
    //Duplication in title
    //check_title_duplication($form['title'], $form['type']['#value'], $form['field_web_dept'], 'field_web_dept', $stat->get_nid());
	
    $stat->set_nid(0);

	// district validation  
	distvalidation($form['field_web_dist']['und']['#value']);
	

    // Check bad character validation for Title and Keywords field
    chkbadchar($form['title']['#value'], $form['title']['#title'], 'title');  
    chkbadchar($form['taxonomy']['tags'][6]['#value'], $form['taxonomy']['tags'][6]['#title'], $form['taxonomy']['tags'][6]['#name']); 
	chkbadchar($form['field_web_keyword']['und'][0]['value']['#value'], $form['field_web_keyword']['und'][0]['value']['#title'], 'field_web_keyword'); 
	chkbadchar($form['field_web_otherscategory']['und'][0]['value']['#value'], $form['field_web_otherscategory']['und'][0]['value']['#title'], 'field_web_otherscategory'); 
	//chkbadchar($form['field_web_url'][0]['value']['#value'], $form['field_web_url']['#title'], 'field_web_url'); 
	
	// minimum length charcter   
  	minilength_validation($form['title']['#value'], 5, $form['title']['#title'], 'title');
  	minilength_validation($form['taxonomy']['tags'][6]['#value'],5, $form['taxonomy']['tags'][6]['#title'], $form['taxonomy']['tags'][6]['#name']); 
	minilength_validation($form['field_web_keyword']['und'][0]['value']['#value'],5, $form['field_web_keyword']['und'][0]['value']['#title'], 'field_web_keyword');
	minilength_validation($form['field_web_otherscategory']['und'][0]['value'][0]['value']['#value'],5, $form['field_web_otherscategory']['und'][0]['value']['#title'], 'field_web_otherscategory');
    // Reference url validation
    /*$reference_url = $form['field_web_url'][0]['value']['#value'];
    $title = $form['field_web_url']['#title'];
    $required = $form['field_web_url']['#required'];
    check_reference_url($reference_url, $title, 'field_web_url', $required);*/
	
	// URL Check
	//$reference_url = $form['field_web_url']['und'][0]['value']['#value'];
	//$reference_url = url_validation($reference_url);
	url_validation($form['field_web_url']['und'][0]['value']['#value']);
	
	/*$reference_url = $form['field_web_url'][0]['value']['#value'];
    
	if(isURL($reference_url) == 0 && $reference_url != '') {
      form_set_error('field_web_url', t('Not a valid URL given in %name field', array(
                                                   '%name' => $form['field_web_url']['und'][0]['value']['#value']['#title'])));    
    }
	elseif ($reference_url == '') {
      form_set_error('field_web_url', t(' %name field is required', array(
                                                   '%name' => $form['field_web_url']['und'][0]['value']['#value']['#title'])));
    }*/
  }
  // function website_form_validation()


  function website_presave_validation($node) {
    $reference_url = $node->field_web_url['und'][0]['value'];
    $node->field_web_url['und'][0]['value'] = url_validation($reference_url);
  }
